﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Legacy_Calculator__Form_Based_.Forms;

namespace Legacy_Calculator__Form_Based_.Forms
{
    public partial class First : Form
    {
        public First()
        {
            InitializeComponent();
        }

        private void chkAyah_CheckedChanged(object sender, EventArgs e)
        {
            
        }

        private void chkIbu_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void chkSuami_CheckedChanged(object sender, EventArgs e)
        {
            chkIstri.Enabled = !chkSuami.Checked;
            chkAnakLaki2.Enabled = chkSuami.Checked || chkIstri.Checked;
            chkAnakPerempuan.Enabled = chkSuami.Checked || chkIstri.Checked;
        }

        private void chkIstri_CheckedChanged(object sender, EventArgs e)
        {
            chkSuami.Enabled = !chkIstri.Checked;
            chkAnakLaki2.Enabled = chkSuami.Checked || chkIstri.Checked;
            chkAnakPerempuan.Enabled = chkSuami.Checked || chkIstri.Checked;
        }

        private void chkAnakLaki2_CheckedChanged(object sender, EventArgs e)
        {
            txtJumlahAnakLaki2.Enabled = chkAnakLaki2.Checked;
        }

        private void chkAnakPerempuan_CheckedChanged(object sender, EventArgs e)
        {
            txtJumlahAnakPerempuan.Enabled = chkAnakPerempuan.Checked;
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            if (chkAyah.Checked) Referensi.Ada(LakiLakiPenerimaWarisan.BAPAK, 1);
            if (chkIbu.Checked) Referensi.Ada(PerempuanPenerimaWarisan.IBU, 1);
            if (chkSuami.Checked) Referensi.Ada(LakiLakiPenerimaWarisan.SUAMI, 1);
            if (chkIstri.Checked) Referensi.Ada(PerempuanPenerimaWarisan.ISTRI, 1);
            if (chkAnakLaki2.Checked) Referensi.Ada(LakiLakiPenerimaWarisan.ANAK_LAKI_LAKI, int.Parse(txtJumlahAnakLaki2.Text));
            if (chkAnakPerempuan.Checked) Referensi.Ada(PerempuanPenerimaWarisan.ANAK_PEREMPUAN, int.Parse(txtJumlahAnakPerempuan.Text));

            if (!Referensi.ApakahAda(LakiLakiPenerimaWarisan.ANAK_LAKI_LAKI))
            {
                Second form = new Second();
                this.Hide();
                form.ShowDialog();
            }
            else
            {
                FinalForm final = new FinalForm();
                final.Show();
            }
        }

        private void First_Load(object sender, EventArgs e)
        {
            txtJumlahAnakLaki2.Enabled = chkAnakLaki2.Checked;
            txtJumlahAnakPerempuan.Enabled = chkAnakPerempuan.Checked;

            chkAnakLaki2.Enabled = chkSuami.Checked || chkIstri.Checked;
            chkAnakPerempuan.Enabled = chkSuami.Checked || chkIstri.Checked;
        }
    }
}
